<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.longtop.com/intelliweb" prefix="e"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Insert title here</title>
	</head>

	<e:View id="view">
	    <script type="text/javascript" src="<c:url value='/scripts/global.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/skin.js'/>"></script>
	    <script type="text/javascript">SkinUtil.getSkin();</script>
	    <script type="text/javascript">SkinUtil.getModuleSkin();</script>
    
		<div id="Invisual Controls" style="min-height: 40px; background-color: LemonChiffon;" >
			<e:Dataset id="Dataset_Index" datasetDefinition="DatasetDefinition_zb.dsd" datasetRef="Dataset_Index" pageSize="10" loadDataCommand="Command_Load">
				 <e:Field name="indexId" dataType="string" label="指标ID" maxLength="32" required="true" validators="checkId"/>
				 <e:Field name="indexName" dataType="string" label="指标名称" maxLength="100"  required="true"/>
				 <e:Field name="indexDesc" dataType="string" label="指标说明" maxLength="200" />
				 <e:Field name="indexType" dataType="string" label="指标类型" maxLength="1" required="true" defaultValue="2" visible="false" />
				 <e:Field name="fitObject" dataType="string" label="适用范围" maxLength="4" dropDown="ListDropDown__FIT_OBJECT" required="true"/>
				 <e:Field name="statCycle" dataType="string" label="统计周期" maxLength="1" dropDown="ListDropDown__STAT_CYCLE" required="true"/>
				 <e:Field name="indexUnit" dataType="string" label="指标单位" maxLength="2" dropDown="ListDropDown__INDEX_UNIT" required="true"/>
				 <e:Field name="indexLevel" dataType="long" label="指标等级" maxLength="22" defaultValue="1" visible="false" />
				 <e:Field name="howDecimal" dataType="string" label="小数位数" maxLength="1" dropDown="ListDropDown__HOW_DECIMAL" required="true"/>
				  <e:Field name="formula" dataType="string" label="指标公式" maxLength="4000" visible="false"/>
				 <e:Field name="formulaSql" dataType="string" label="指标公式sql" maxLength="4000" visible="false"/>
				 <e:Field name="indexDepend" dataType="string" label="指标依赖关系" maxLength="1" visible="false"/>
				 <e:Field name="dataType" dataType="string" label="数据类型" maxLength="1" visible="false"/>
				  <e:Field name="storeDate" dataType="string" label="数据保存日期" maxLength="1" required="true" dropDown="ListDropDown__STAT_CYCLE" />
				 
				  <e:Field name="fromTableName" dataType="string" label="数据来源" maxLength="1" visible="false"/>
				   <e:Field name="fromColumnName" dataType="string" label="数据来源" maxLength="1" visible="false"/>
				    <e:Field name="fromCondition" dataType="string" label="数据来源" maxLength="1" visible="false"/>
				 <e:Field name="fromAvgType" dataType="string" label="数据来源" maxLength="1" visible="false"/>
				  <e:Field name="fromStatus" dataType="string" label="数据来源" maxLength="1" visible="false"/>
				
				 <e:Field name="sortNo" dataType="long" label="排序号" maxLength="22" required="true"/>
				 <e:Field name="remark" dataType="string" label="备注" maxLength="400" />
				 <e:Field name="createTime" dataType="date" label="创建时间" maxLength="7" readOnly="true"/>
				 <e:Field name="createUserId" dataType="string" label="创建人ID" maxLength="32" visible="false"/>
				 <e:Field name="createUserName" dataType="string" label="创建人名称" maxLength="100" readOnly="true"/>
				 <e:Field name="createOrgId" dataType="string" label="创建机构ID" maxLength="32" visible="false"/>
				 <e:Field name="createOrgName" dataType="string" label="创建机构名称" maxLength="100" readOnly="true"/>
				 <e:Field name="orgLevelCode" dataType="string" label="机构级次" maxLength="100" readOnly="true"/>
				 <e:Field name="updateUserId" dataType="string" label="修改人ID" maxLength="32" readOnly="true"/>
				 <e:Field name="updateUserName" dataType="string" label="修改人" maxLength="100" readOnly="true"/>
				 <e:Field name="updateTime" dataType="date" label="修改时间" maxLength="7" readOnly="true"/>
			</e:Dataset>
			
			<e:Command id="Command_Delete" action="com.longtop.perform.zb.index.web.IndexDlBasicListAction" method="deleteIndex" validateRequired="true" onExecuteSuccess="Command_Delete_onExecuteSuccess(command)" showHintInfoOnSuccess="false">
				<e:DatasetInfo name="DatasetInfo1" dataset="Dataset_Index" alwayRefreshClient="false" submitType="changes"></e:DatasetInfo>
			</e:Command>
			<e:Command id="Command_Search" action="com.longtop.perform.zb.index.web.IndexDlBasicListAction" method="searchIndex" submitForm="true" submitFormScope="all" validateRequired="true">
				<e:DatasetInfo name="DatasetInfo2" dataset="Dataset_Index" alwayRefreshClient="true" submitType="all"></e:DatasetInfo>
			</e:Command>
			<e:Command id="Command_Load" action="com.longtop.perform.zb.index.web.IndexDlBasicListAction" method="loadIndex" showHintInfoOnSuccess="false">
				<e:DatasetInfo name="DatasetInfo3" dataset="Dataset_Index" alwayRefreshClient="true"></e:DatasetInfo>
			</e:Command>
			
			<e:Command id="Command_Save" action="com.longtop.perform.zb.index.web.IndexDxListAction" method="saveIndex" submitForm="true" validateRequired="true" onExecuteSuccess="Button_Search_onClick()">
				<e:DatasetInfo name="DatasetInfo1" dataset="Dataset_Index" alwayRefreshClient="false" submitType="changes"></e:DatasetInfo>
			</e:Command>
			
			<e:PatternValidator pattern="^[a-zA-Z]{1}([a-zA-Z0-9]|[_]){1,31}$" id="checkId" errorMessage="ID必须为2位数以上，以字母开头的字母，下划线，数字的组合"></e:PatternValidator>
			
			<e:ListDropDown id="ListDropDown__FIT_OBJECT" fixed="true" autoDropDown="true">
			</e:ListDropDown>
			
			<e:ListDropDown id="ListDropDown__STAT_CYCLE" fixed="true" autoDropDown="true">
			</e:ListDropDown>
			<e:ListDropDown id="ListDropDown__INDEX_UNIT" fixed="true" autoDropDown="true">
			</e:ListDropDown>
			<e:ListDropDown id="ListDropDown__HOW_DECIMAL" fixed="true" autoDropDown="true">
			</e:ListDropDown>
			
			
			<e:LookupDropDown id="LookupDropDown_Org" path="/jsp/framework/sys/org/orgDropdown.jsp"	windowWidth="600" windowHeight="400" 
				autoDropDown="true" fixed="true" onSelect="LookupDropDown_Org_onSelect(dropdown,iframe,text)" windowCaption="选择机构">
			</e:LookupDropDown>
		</div>

		<body>
			<e:Page id="ePage" action="com.longtop.perform.zb.index.web.IndexDlBasicListAction" style="min-height: 80px; width: 100%; height: 100%;" onAfterLoadPage="ePage_onAfterLoadPage()">
				<table style="width: 100%; height: 100%;" border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
					<tr>
						<td valign="top" width="100%">
							<table style="text-align: left; width: 100%;" border="0" cellpadding="3" cellspacing="3" >
								<tr>
									<td>
										<e:GroupBox id="GroupBox1" caption="查询条件" style="height: 100%; width:100%;">
											<table style="text-align: left; width: 100%;" border="0" cellpadding="3" cellspacing="3" width="100%" align="center">
												<tr>
													<td align="right" nowrap="nowrap">
														<e:Label id="Label_indexId" caption="指标ID"></e:Label>
													</td>
													<td align="left">
														<e:Text id="Text_indexId" style="width:100px;"></e:Text>
													</td>
													<td align="right" nowrap="nowrap">
														<e:Label id="Label_indexName" caption="指标名称"></e:Label>
													</td>
													<td align="left">
														<e:Text id="Text_indexName" style="width:100px;"></e:Text>
													</td>
													<td align="right" nowrap="nowrap">
														<e:Label id="Label_fitObject" caption="适用对象"></e:Label>
													</td>
													<td align="left">
														<e:Text id="Text_fitObject" style="width:100px;" dropDown="ListDropDown__FIT_OBJECT"></e:Text>
													</td>
													<td></td>
												</tr>
												<tr>
													<td align="right" nowrap="nowrap">
														<e:Label id="Label_createOrg" caption="创建机构"></e:Label>
													</td>
													<td align="left">
														<e:Text id="Text_createOrg" style="width:100px;" dropDown="LookupDropDown_Org"></e:Text>
													</td>
													<td align="right" nowrap="nowrap">
														<e:Label id="Label_statCycle" caption="统计周期"></e:Label>
													</td>
													<td align="left">
														<e:Text id="Text_statCycle" style="width:100px;" dropDown="ListDropDown__STAT_CYCLE"></e:Text>
													</td>
													<td align="right" nowrap="nowrap">
													</td>
													<td align="left">
													</td>
													<td align="left" width="99%">
														<e:Button id="Button_Search" style='height: 22px; width: 70px' caption="查询" command="Command_Search" icon="/images/query.gif" onClick="Button_Search_onClick()"></e:Button>
													</td>
												</tr>
											</table>
										</e:GroupBox>
									</td>
								</tr>	
								<tr>
									<td>
										<table style="text-align: left; width: 100%;" border="0" cellpadding="0" cellspacing="0">
											<tr>
												<td height="27px" width="1%">
													<e:RecordNavigator id="RecordNavigator_Index" dataset="Dataset_Index" showNavigatorButton="false">
														<e:RecordButton id="RecordButton_insert" label="新增" onClick="insertRecord" icon="/images/add.gif"></e:RecordButton>
														<e:RecordButton id="RecordButton_delete" label="删除" onClick="deleteRecord" icon="/images/delete.gif"></e:RecordButton>
														<e:RecordButton id="RecordButton_save" label="保存" icon="/images/submit.gif" onClick="RecordButton_save_onClick()"></e:RecordButton>
													</e:RecordNavigator>
												</td>
												<td align="left" width="99%"><e:PageNavigator id="PageNavigator_Index" dataset="Dataset_Index" showRecordNum="true"></e:PageNavigator></td>
											</tr>
										</table>
									</td>
								</tr>
								<tr>
									<td>
										<e:Grid id="Grid_Index" style="width: 100%; height: 100%;" showIndex="true" dataset="Dataset_Index" onClick="Grid_Index_onClick()">
										</e:Grid>
									</td>
								</tr>
							</table>
						</td>
					</tr>
			    </table>
			</e:Page>
		</body>
	</e:View>
</html>	

<script type="text/javascript">
	//init
	function ePage_onAfterLoadPage(){
		var _item1=$J("ListDropDown_indexType_0009").getItemByValue("1");
		$J("ListDropDown_indexType_0009").removeItem(_item1) ;
		
	}
	
	//查询
	function Button_Search_onClick(){
	    Command_Search.execute();
	}
	
	
	//单击记录,确定主键是否可编辑
	function Grid_Index_onClick(){
		var element = event.srcElement;
		if(element.isDataCell){
			if(element.isDataCell){
		        var currentRecord = element.record;
		        if(currentRecord.state == Constant.RECORD.STATE_NEW || currentRecord.state == Constant.RECORD.STATE_INSERT) {
	          		currentRecord.dataset.getField("indexId").setReadOnly(false);
	          		currentRecord.dataset.getField("indexName").setReadOnly(false);
	          		currentRecord.dataset.getField("fitObject").setReadOnly(false);
	          	} else{
			        currentRecord.dataset.getField("indexId").setReadOnly(true);
			        currentRecord.dataset.getField("indexName").setReadOnly(true);
			        currentRecord.dataset.getField("fitObject").setReadOnly(true);
	       		}
			}
		}
	}
	
	//Text选择部门
	function LookupDropDown_Org_onSelect(dropdown,iframe,text){
		var dataset = $J(iframe.Dataset_Org);
		var node = $J(iframe.DataTree_Org).getCurrentNode();
		if(dataset && node!=null&& node.level > 1){//除去根节点
		    var record = dataset.getCurrentRecord();
		    if(typeof record != "undefined" && record != null){
		    	$J("Text_createOrg").setValue(record.getValue("orgId"),record.getValue("orgName"));
		    }
		}
		if(dataset && node!=null && node.level == 1){//清空
			$J("Text_createOrg").setValue("");
		}
	}
	
	//保存
	function RecordButton_save_onClick(){
	    Command_Save.execute();
	}
		
</script>